<template>
  <div class="table-box">
    <ProTable ref="proRef">
      <template #tableHeader>
        <el-button type="primary" @click="operaRule('menu', 'add')">新增菜单</el-button>
        <el-button type="default">批量删除</el-button>
      </template>
    </ProTable>
    <RuleDialog ref="diaRef"></RuleDialog>
  </div>
</template>

<script setup lang="ts">
import type { RuleType } from "@/interface/system/rule";
import ProTable from "@/components/ProTable/index.vue";
import RuleDialog from "./components/ruleDialog.vue";
import { initFormData } from "./data/index";
import { ref } from "vue";
import { FormProps } from "./interface/form";
const proRef = ref<InstanceType<typeof ProTable> | null>();
const diaRef = ref<InstanceType<typeof RuleDialog> | null>();
const operaRule = (type: RuleType, opera_type: "add" | "edit" = "add") => {
  let params: Tool.AcceptParams<FormProps> = { row: JSON.parse(JSON.stringify(initFormData)) };
  params.getTable = proRef.value.getTableList;
  type === "menu" ? (params.row.rule_type = "menu") : (params.row.rule_type = "api");
  console.log(opera_type);
  diaRef.value.acceptParams(params);
};
</script>

<style></style>
